﻿Imports KOR.Helpers
Imports KOR.Helpers.Data
Imports KOR.Support

Namespace BL


    Public Module Colors

#Region "Colors_DML"

        Public Function InsertColor(dict As Dictionary(Of String, Object)) As Integer
            Return DDA.Insert("Colors", dict)
        End Function

        Public Function UpdateColor(dict As Dictionary(Of String, Object), ColorID As Integer) As Integer
            Return DDA.Update("Colors", dict, "ColorID=" & ColorID)
        End Function

        Public Function DeleteColor(ByVal ColorID As Integer) As Integer
            Return DDA.Delete("Colors", "ColorID=" & ColorID, False)
        End Function

#End Region

#Region "Colors_Selection"

        Public Function GetAllColors() As IDataReader
            Dim sql As String = "SELECT * FROM Colors Order By ColorID DESC"
            Return DDA.SelectData(sql)
        End Function

        Public Function GetColors(searchFor As String, criteria As String, startRowIndex As Integer, maximumRows As Integer, SortBy As String) As IDataReader
            Dim sql As String
            sql = "SELECT * FROM Colors "

            If SortBy = "" Then SortBy = " CreatedDate Desc"

            Return DDA.SelectDataPaginated(sql, startRowIndex, maximumRows, SortBy)
        End Function

        Public Function ColorsCount(searchFor As String, criteria As String) As Integer
            Dim sql As String
            sql = "SELECT * FROM Colors "
            Return DDA.SelectDataCount(sql)
        End Function

#End Region

    End Module
End Namespace